-
Notifications
You must be signed in to change notification settings - Fork 99
Fix build errors in mingw #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build errors in mingw #71
Conversation
Cryptic linking errors would appear when trying to compile with mingw The errors mentioned __mingw_uuidof<ID3D12Heap>, __mingw_uuidof<ID3D12Device8> and __mingw_uuidof<ID3D12Device10> as undefined references.
Where do these headers come from? Why are they needed? And why not include them always? Is I can see "guiddef.h" in the standard Windows SDK, but I can't see "dxguids.h" in either Windows SDK or the DirectX 12 Agility SDK. |
Hi! Why installing from mingw or even native LinuxThere are multiple reasons:
Header files
Without
This is a cryptic error because it indicates a library is missing, but for some reason a header is what's missing.
dxguids.h is only available if using the DirectX Headers, but not the Windows SDK headers.
This is a good question. Since the problem appears with standard mingw headers included in Ubuntu 24.04, IMO ideally this should be autodetected. Since this path is meant for mingw (i.e. GCC) the header's presence could be detected: #if !defined(_MSC_VER)
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
#if !__has_include(<dxguids.h>)
#error "mingw or gcc detected. dxguids.h is needed. You can grab it from https://github.com/microsoft/DirectX-Headers or if you're on Ubuntu just run sudo apt install directx-headers-dev"
#endif
#include <guiddef.h>
#include <dxguids.h>
#endif
#endif But I live that decision up to you. |
40f8aa5
into
GPUOpen-LibrariesAndSDKs:master
OK, thank you for this contribution and for the explanation. |
This commit break building with mingw because |
It is necessary as I explained it. Without this PR, it will compile but it won't link when compiling from Linux.
Does this snippet work for you?
Does it hit the "#error" block? Does it compile fine? |
Yes the snippet compiles fine. I tested using MSYS2 and ucrt64 and clang64 environments. If I revert this PR then compiling and linking works for me. I don't want to install DirectX headers because it's unnecessary. If it does not work for you, you need to fix it in your project. |
I cannot accept a change that uses |
I don't think the otolm claimed he could compile mingw compiled fine when he added the snippet, which means that The Or we could do: #if !defined(_MSC_VER)
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
#if defined(__has_include)
#if !__has_include(<dxguids.h>)
#error "mingw or gcc detected. dxguids.h is needed. You can grab it from https://github.com/microsoft/DirectX-Headers or if you're on Ubuntu just run sudo apt install directx-headers-dev"
#endif
#endif
#include <guiddef.h>
#include <dxguids.h>
#endif
#endif Basically if |
There was a misunderstanding you meant replacing the code with the snippet. If I do this then I get
If I revert this PR then the project builds. That is why I am saying that it's unnecessary. |
Alternative solution I can think of: This probably got fixed on a newer MINGW version, but now Linux distros will be stuck for a long time due to how LTS releases work. // On older mingw versions, using the Agility SDK will cause linker errors unless dxguids.h is included.
#if defined( __MINGW64_VERSION_MAJOR ) && defined( __MINGW64_VERSION_MINOR ) && \
defined( __MINGW64_VERSION_BUGFIX ) && defined( __ID3D12Device8_INTERFACE_DEFINED__ )
# define D12MA_MAKE_MINGW_VERSION( x, y, z ) ( ( x << 20u ) | ( y << 10u ) | ( z ) )
# if D12MA_MAKE_MINGW_VERSION( __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR, \
__MINGW64_VERSION_BUGFIX ) <= D12MA_MAKE_MINGW_VERSION( 11, 0, 1 )
# if defined( __has_include )
# if !__has_include( <dxguids.h>)
# error \
"mingw or gcc detected. dxguids.h is needed. You can grab it from https://github.com/microsoft/DirectX-Headers or if you're on Ubuntu just run sudo apt install directx-headers-dev"
# endif
# endif
# include <guiddef.h>
# include <dxguids.h>
# endif
# undef D12MA_MAKE_MINGW_VERSION
#endif No need to check @oltolm can you confirm this compiles for you? |
Yes this compiles for me. |
Is this going to be fixed? This breaks building on Windows and this is a Windows library. I don't know why it even needs to support Linux. |
This PR incorporates fixes for issues reported in GPUOpen-LibrariesAndSDKs#71
Opened #77 to fix it. |
Cryptic linking errors would appear when trying to compile with mingw
The errors mentioned __mingw_uuidof,
__mingw_uuidof and __mingw_uuidof as undefined references.